package com.project.school_flate.config.tableListener;

import com.mybatisflex.annotation.SetListener;

public class generateUrlListener implements SetListener {

//    @SneakyThrows
//    @Override
//    public Object onSet(Object entity, String property, Object value) {
//        List<String> list = new ArrayList<>();
//        list.add("image");
//        list.add("bannerImage");
//        list.add("memberImage");
//        list.add("idFront");
//        list.add("idOpposite");
//        list.add("poster");
//        list.add("businessLicense");
//        list.add("operatePermit");
//        if(list.contains(property)){
//            // 取得对象的所有属性
//            Class poClass = entity.getClass();
//            if("ShopType".equals(poClass.getSimpleName())){
//                ShopType shopType = (ShopType) entity;
//                shopType.setImageUrlList();
//            }else if("ShopType".equals(poClass.getSimpleName())){
//                ShopType shopType = (ShopType) entity;
//                shopType.setImageUrlList();
//            }else if("ShopType".equals(poClass.getSimpleName())){
//                ShopType shopType = (ShopType) entity;
//                shopType.setImageUrlList();
//            }
////            Field[] poFields = poClass.getDeclaredFields();
////            for (Field f : poFields) {
////                String fieldName = f.getName();
//////                if(fieldName.equals(property + "UrlList")){
//////                    //构建执行方法
//////                    String fieldFunction = "set" + StringUtils.capitalize(fieldName);
//////                    //获取执行方法
//////                    Method m1 = poClass.getMethod(fieldFunction);
//////                    //执行赋值方法ImageUtils.splitImage(value.toString())
//////                    m1.invoke("aaaa");
//////                }
////            }
//        }
//        return value;
//    }
//
//    /**
//     * 首字母大写
//     *
//     * @param fieldName
//     * @return
//     */
//    public static String firstToBig(String fieldName) {
//        if (fieldName != null && fieldName != "") {
//            fieldName = fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
//        }
//        return fieldName;
//    }

    @Override
    public Object onSet(Object entity, String property, Object value) {
//        if("ShopType".equals(entity.getClass().getSimpleName())) {
//            if("image".equals(property)){
//                ShopType shopType = (ShopType) entity;
//                shopType.setImageUrlList();
//            }else if("image2".equals(property)){
//                ShopType shopType = (ShopType) entity;
//                shopType.setImage2UrlList();
//            }
//        }
        return value;
    }

}
